package com.sjzd.message;

import com.sjzd.entity.Bullet;
import com.sjzd.exception.NullObjectException;
import com.sjzd.menu.GameMenu;

public class BulletMessageProcessStrategy extends MessageProcessStrategy<BulletStatusMessage> {
    public BulletMessageProcessStrategy(GameMenu gameMenu) {
        super(gameMenu);
    }

    @Override
    public void process(BulletStatusMessage msg) throws NullObjectException {
        if (msg.isExist) { // 说明此条信息为发射信息
            Bullet bullet = gameMenu.loadOtherBullet(msg.id, msg.X, msg.Y, msg.sinX, msg.sinY);
            bullet.isExist = true;
            gameMenu.addBullet(bullet);
        } else {
           gameMenu.removeBullet(msg.id);
        }
    }
}
